package com.weixing.mall.util.image;

import net.coobird.thumbnailator.Thumbnails;
import net.coobird.thumbnailator.util.ThumbnailatorUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * google Thumbnailator图像处理工具类
 *
 * @Author: kfc
 * @Description: <br/>
 * Date:Create in 2019/8/21 15:47
 * @Modified By:
 */
public class ThumbnailatorUtil {

    public static void test(){
        try {
            FileInputStream fi = new FileInputStream(new File("D:\\timg.jpg"));
//            Thumbnails.of("D:\\timg.jpg").scale(0.5).toFile("D:\\test_nail_5.jpg");
//            Thumbnails.of("D:\\timg.jpg").scale(0.8).toFile("D:\\test_nail_8.jpg");
//            Thumbnails.of("D:\\timg.jpg").scale(0.3).toFile("D:\\test_nail_3.jpg");

            Thumbnails.of(fi).scale(0.3).toFile("D:\\test_nail_3.jpg");
            Thumbnails.of(fi).scale(0.5).toFile("D:\\test_nail_5.jpg");
            Thumbnails.of(fi).scale(0.8).toFile("D:\\test_nail_8.jpg");

        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    public static void main(String[] args) {
        test();
    }
}
